package cn.kailangtu.dataspot.data.context;

import android.graphics.Color;
import android.widget.TextView;

import java.util.Date;

import cn.kailangtu.dataspot.R;

public class KeyboardTimeContext {
    public static int year,month,day,hour,minute,second;
    public static String tipMsg;
    private  static TextView selectedView;
    private static int normalColor;
    public static TextView getSelectedView()
    {
        return selectedView;
    }

    public static void setSelectedView(TextView newView)
    {

        if(selectedView != null)
        {

            if(selectedView.getTag().equals("cancel")){
                selectedView.setBackgroundResource(R.drawable.button_selection_normal);
            }
            else if(selectedView.getTag().equals("save")){
                selectedView.setBackgroundResource(R.drawable.button_selection_normal);
            }
            selectedView.setTextColor(normalColor);
        }
        normalColor = newView.getCurrentTextColor();
        selectedView = newView;
        newView.setTextColor(Color.parseColor("#FF0000"));

        if(selectedView.getTag().equals("cancel")){
            selectedView.setBackgroundResource(R.drawable.button_selection_selected);
            selectedView.setTextColor(Color.parseColor("#FFFFFF"));
        }
        else if(selectedView.getTag().equals("save")){
            selectedView.setBackgroundResource(R.drawable.button_selection_selected);
            selectedView.setTextColor(Color.parseColor("#FFFFFF"));
        }
    }

    public static void entry(){
        if( selectedView != null && selectedView.getTag() != null ){
            String tag = selectedView.getTag().toString();
            switch(tag)
            {
                case "save":
                case "cancel":
                    selectedView.callOnClick();
                    break;
                case "year":
                    year++;
                    if(year < 2020 || year > 2035)
                    {
                        year = 2020;
                    }
                    break;
                case "month":
                    month++;
                    if(month < 1 || month > 12)
                    {
                        month = 1;
                    }
                    break;
                case "day":
                    day++;
                    if(day < 1 || day > 31)
                    {
                        day = 1;
                    }
                    break;
                case "hour":
                    hour++;
                    if(hour > 23 )
                    {hour = 0;}
                    break;
                case "minute":
                    minute++;
                    if(minute > 59)
                    {
                        minute = 0;
                    }
                    break;
                case "second":
                    second++;
                    if(second > 59)
                    {
                        second = 0;
                    }
                    break;
            }

        }
    }


}
